# Maintainer: Sergej Pupykin <arch+pub@sergej.pp.ru>

pkgname=psi-plugins
pkgver=1.5
pkgrel=2
pkgdesc="Additional features for Psi"
arch=('loong64' 'x86_64')
url="https://psi-im.org"
license=('GPL2')
depends=('psi')
makedepends=('libotr' 'tidy')
optdepends=('libotr: OTR plugin'
            'tidy: OTR plugin')
source=("$pkgname-$pkgver.tar.gz::https://github.com/psi-im/plugins/archive/$pkgver.tar.gz"
        'psiplugin.pri')
sha256sums=('1857b9dc89ef0d548697207b3a56283f2d67c0de75cc66bf863936a58150401e'
            '2edc9f76e032e25044f0d16376194127c07b3372195482236901222ebec11a75')

prepare() {
    cp -v psiplugin.pri plugins-$pkgver/

    cd plugins-$pkgver
    patch -p1 <<EOP
diff -wbBur plugins-1.5/generic/screenshotplugin/screenshot.cpp plugins-1.5.q/generic/screenshotplugin/screenshot.cpp
--- plugins-1.5/generic/screenshotplugin/screenshot.cpp	2018-11-05 10:55:49.000000000 +0300
+++ plugins-1.5.q/generic/screenshotplugin/screenshot.cpp	2021-10-07 22:47:29.239540853 +0300
@@ -32,6 +32,7 @@
 #include <QCloseEvent>
 #include <QDesktopServices>
 #include <QClipboard>
+#include <QtGui/QPainterPath>
 
 
 #include "screenshot.h"
EOP
}

build() {
    cd plugins-$pkgver
    for plugin in generic/* unix/*; do
        if [ -d "$plugin" ]; then
            (cd "$plugin" && qmake-qt5 PREFIX="/usr" QMAKE_STRIP= && make)
        fi
    done
}

package() {
    cd plugins-$pkgver
    for plugin in generic/* unix/*; do
        if [ -d "$plugin" ]; then
            (cd "$plugin" && make INSTALL_ROOT="$pkgdir" install)
        fi
    done
}
